/**
 * Created by duwei on 2019/2/15.
 */
var TIANHU = 0x1; 	//天胡1
var DIHU = 0x2; 	//地胡2
var TI = 0x4;		//提4
var WEI = 0x8;	    //偎8
var CHOUWEI = 0x10; //臭畏16
var HU = 0x20;		//胡32
var PAO = 0x40;		//跑64
var PENG = 0x80;	//碰128
var CHI = 0x100;	//吃256
var DENGHU = 0x800; //等胡
var HUDENGHU = 0x1000;//胡等胡
var GUO = 0x10000;  //65536

var mAction = {
    acts: {
        'chi': CHI,
        'peng': PENG,
        'ti': TI,
        'pao': PAO,
        'hu': HU,
        'tianhu': TIANHU,
        'wei': WEI,
        'chouwei': CHOUWEI,
        'denghu': DENGHU,
        'hudenghu':HUDENGHU,
        'none': GUO
    },
    combos: {},
    hx: {},
    outCards: {},
    chuCards: {},
    leftCardCount: 0,
    init: function () {
    },
    initGame: function () {
        mAction.combos = {
            0: [],
            1: [],
            2: [],
            3: []
        };
        mAction.hx = {
            0: 0,
            1: 0,
            2: 0,
            3: 0
        };
        mAction.showHx = {
            0: 0,
            1: 0,
            2: 0,
            3: 0
        };
        mAction.outCards = {
            0: [],
            1: [],
            2: [],
            3: []
        };
        mAction.chuCards = {
            0: [],
            1: [],
            2: [],
            3: []
        };
        mAction.leftCardCount = 80;
    },
    /**
     * 使用
     * @param card
     * @returns {boolean}
     */
    isInOpenList: function (card) {
        var openList = mAction.combos[0];
        for (var i = 0; i < openList.length; i++) {
            var comb = openList[i];
            var cardInCombo = comb.cards[0];
            if (card == cardInCombo) {
                return true;
            }
        }
        return false;
    },
    /**
     * 使用
     * @param act
     * @returns {*}
     */
    getActionString: function (act) {
        var str = '';
        var acts = mAction.acts;
        for (var key in acts) {
            if (acts[key] == act) {
                return key;
            }
        }
        return str;
    },
    // getActionByString: function (actStr) {
    //     var act = mAction.acts[actStr];
    //     return act;
    // },
    /**
     * 使用
     * @param target
     * @param typ
     * @returns {boolean}
     */
    checkOpen: function (target, typ) {
        //如果是录像回放不判断
        if (999999 == target) {
            return true;
        }
        if ((typ & target) != 0) {
            return true;
        }
        return false;
    },
    /**
     * 使用
     * @param index
     * @param actList
     * @returns {number}
     */
    getBTAct: function (index, actList) {
        //if(index == 3)return true;
        for (var i = 0; i < actList.length; i++) {
            var act = actList[i];
            if (index == 1 && act == CHI) {
                return CHI;
            } else if (index == 2 && act == PENG) {
                return PENG;
            } else if (index == 0 && act == HU) {
                return HU;
            } else if (index == 3 && act == GUO) {
                return GUO;
            } else if (index == 3 && act == WEI) {
                return WEI;
            } else if (index == 3 && act == PAO) {
                return PAO;
            } else if (index == 4 && act == DENGHU) {
                return DENGHU;
            }
        }
        return 0;
    },
};